fontchooser: Handle families without faces
authorMatthias Clasen <mclasen@redhat.com>
Sun, 20 Sep 2020 14:39:24 +0000 (10:39 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 20 Sep 2020 14:59:37 +0000 (10:59 -0400)
This might seem useless, but I've met fonts
where pango_font_family_get_face (family, NULL)
return NULL. Handle it without criticals.

gtk/gtkfontchooserwidget.c

index 0f380f34b91ca2c516655d35538860594e92fcb0..171ef5c8201d62961a12a94883919057e24060aa 100644 (file)
@@ -738,10 +738,13 @@ get_font_attributes (GObject  *ignore,
         face = pango_font_family_get_face (item, NULL);
       else
         face = item;
-      font_desc = pango_font_face_describe (face);
-      attribute = pango_attr_font_desc_new (font_desc);
-      pango_attr_list_insert (attrs, attribute);
-      pango_font_description_free (font_desc);
+      if (face)
+        {
+          font_desc = pango_font_face_describe (face);
+          attribute = pango_attr_font_desc_new (font_desc);
+          pango_attr_list_insert (attrs, attribute);
+          pango_font_description_free (font_desc);
+        }
     }
 
   return attrs;
@@ -1044,6 +1047,9 @@ add_languages_from_font (GtkFontChooserWidget *self,
   else
     face = PANGO_FONT_FACE (item);
 
+  if (!face)
+    return;
+
   desc = pango_font_face_describe (face);
   pango_font_description_set_size (desc, 20);